package com.wn.EDI.util;

import java.io.IOException;
import java.io.Writer;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;

public class StandaloneWriter extends XMLWriter
{
  protected void writeDeclaration()
    throws IOException
  {
    OutputFormat format = getOutputFormat();
    String encoding = format.getEncoding();
    if (!format.isSuppressDeclaration()) {
      this.writer.write("<?xml version=\"1.0\"");
      if (!format.isOmitEncoding()) {
        if (encoding.equals("UTF8"))
          this.writer.write(" encoding=\"UTF-8\"");
        else
          this.writer.write(" encoding=\"" + encoding + "\"");
      }
      this.writer.write(" standalone=\"no\"");
      this.writer.write("?>");
      if (format.isNewLineAfterDeclaration())
        println();
    }
  }
}